<template>
  <div class="app-container">
    <el-form size="large" :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="100px">
      <el-form-item label="项目名称" prop="projectName">
        <el-input @input="handleQuery" v-model="queryParams.projectName" placeholder="请输入项目名称" clearable
          @keyup.enter="handleQuery" />
      </el-form-item>
      <el-form-item label="销售负责人" prop="saleRole">
        <el-select @change="handleQuery" v-model="queryParams.saleRole" placeholder="请选择" clearable
          style="width: 200px">
          <el-option v-for="dict in saleRoleList" :key="dict.participantId" :label="dict.participanName"
            :value="dict.participantId" />
        </el-select>
      </el-form-item>

      <el-form-item label="客户名称" prop="customerName">
        <el-input @input="handleQuery" v-model="queryParams.customerName" placeholder="请输入客户名称" clearable
          @keyup.enter="handleQuery" />
      </el-form-item>

      <el-form-item>
        <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
        <el-button icon="Refresh" @click="resetQuery">重置</el-button>
        <el-button type="primary" plain icon="Plus" @click="handleAdd">新增</el-button>
      </el-form-item>
    </el-form>


    <el-table v-loading="loading" :data="projectList" border>
      <el-table-column v-for="col in visibleColumns" :key="col.prop" :prop="col.prop" :label="col.label"
        :align="'center'"
        :show-overflow-tooltip="['contractAmount', 'settlementAmount', 'housekeeperName'].includes(col.prop)"
        :width="getWidth(col.prop)">
        <!-- 特殊列的插槽处理 -->
        <template #default="scope" v-if="['approvalDate', 'planDate', 'acceptTime'].includes(col.prop)">
          <span>{{ parseTime(scope.row[col.prop], "{y}-{m}-{d}") }}</span>
        </template>
      </el-table-column>

      <!-- 固定操作列 -->
      <el-table-column label="操作" fixed="right" :width="userStore.isMobile ? 180 : 210" align="center"
        class-name="small-padding fixed-width">
        <template #default="scope">
          <el-button link type="primary" :icon="userStore.isMobile ? '' : 'Edit'" @click="handleUpdate(scope.row)">查看 |
            修改</el-button>
          <!-- <el-button link type="primary" :icon="userStore.isMobile ? '' : 'Edit'"
            @click="handleUpdate(scope.row)">修改</el-button> -->
          <el-button v-if="scope.row.saleCom == '1'" link type="primary" :icon="userStore.isMobile ? '' : 'Delete'"
            @click="handleDelete(scope.row)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum"
      v-model:limit="queryParams.pageSize" @pagination="getList" />

    <!-- 添加或修改绩效基本信息对话框 -->
    <el-dialog :title="title" fullscreen v-model="open" width="800px" append-to-body>
      <el-tabs type="border-card" v-model="activeName" @tab-click="handleClick" :before-leave="beforeTabLeave">
        <el-tab-pane label="项目信息" name="first">
          <el-form ref="projectRef" :disabled="form.saleCom == '2'" :model="form" label-position="left" :rules="rules"
            :label-width="userStore.isMobile ? '100px' : '120px'" size="large">


            <!-- 发起人相关 -->
            <el-row :gutter="userStore.isMobile ? 10 : 21">
              <el-col :span="userStore.isMobile ? 24 : 7">
                <el-form-item label="发起人" prop="createDeptName">
                  <el-input disabled v-model="form.createUserName" style="width: 100%" />
                </el-form-item>
              </el-col>
              <el-col :span="userStore.isMobile ? 24 : 7">
                <el-form-item label="发起人所在部门" prop="createDeptName">
                  <el-input disabled v-model="form.createDeptName" style="width: 100%" />
                </el-form-item>
              </el-col>
              <el-col :span="userStore.isMobile ? 24 : 7">
                <el-form-item label="发起时间" prop="startDate">
                  <el-date-picker disabled clearable v-model="form.createTime" type="datetime"
                    value-format="YYYY-MM-DD HH:mm:ss" placeholder="请选择发起时间" style="width: 100%">
                  </el-date-picker>
                </el-form-item>
              </el-col>
            </el-row>

            <el-row :gutter="userStore.isMobile ? 10 : 21">
              <el-col :span="userStore.isMobile ? 24 : 7">
                <el-form-item label="项目名称" prop="projectName">
                  <el-input v-model="form.projectName" placeholder="请输入项目名称" style="width: 100%" />
                </el-form-item>
              </el-col>

              <el-col :span="userStore.isMobile ? 24 : 7">
                <el-form-item label="管家婆项目" prop="housekeeperProject">
                  <el-select v-model="form.housekeeperProject" clearable filterable remote reserve-keyword
                    placeholder="请输入关键字" :remote-method="selectCompany" :loading="loadingQuery" style="width: 100%"
                    @change="setHousekeeperName">
                    <el-option v-for="item in companyList" :key="item.id" :label="item.companyName" :value="item.id" />
                  </el-select>
                </el-form-item>
              </el-col>

              <el-col :span="userStore.isMobile ? 24 : 7">
                <el-form-item label="项目类型" prop="projectType">
                  <el-select @change="setProjectTypeName" v-model="form.projectType" placeholder="请选择项目类型"
                    style="width: 100%">
                    <el-option v-for="dict in project_type" :key="dict.value" :label="dict.label"
                      :value="dict.value"></el-option>
                  </el-select>
                </el-form-item>
              </el-col>

            </el-row>




            <!-- 金额字段 -->
            <el-row :gutter="userStore.isMobile ? 10 : 21">
              <el-col :span="userStore.isMobile ? 24 : 7">

                <el-form-item label="预收款日期" prop="approvalDate">
                  <el-date-picker clearable v-model="form.paymentDate" type="date" value-format="YYYY-MM-DD"
                    placeholder="预收款日期" style="width: 100%">
                  </el-date-picker>
                </el-form-item>

              </el-col>
              <el-col :span="userStore.isMobile ? 24 : 7">
                <el-form-item label="合同金额(元)" prop="contractAmount">
                  <el-input type="number" @wheel.native.prevent v-model="form.contractAmount" placeholder="请输入合同金额"
                    style="width: 100%">
                  </el-input>
                </el-form-item>
              </el-col>
              <el-col :span="userStore.isMobile ? 24 : 7">
                <el-form-item label="结算金额(元)" prop="settlementAmount">
                  <el-input type="number" @wheel.native.prevent v-model="form.settlementAmount" placeholder="请输入结算金额"
                    style="width: 100%">
                  </el-input>
                </el-form-item>
              </el-col>
            </el-row>

            <!-- 其他行依此类推 -->

            <el-row :gutter="userStore.isMobile ? 10 : 21">
              <el-col :span="userStore.isMobile ? 24 : 7">
                <el-form-item label="合同签订日期" prop="planDate">
                  <el-date-picker clearable v-model="form.planDate" type="date" value-format="YYYY-MM-DD"
                    placeholder="请选择合同签订日期" style="width: 100%">
                  </el-date-picker>
                </el-form-item>
              </el-col>


              <el-col :span="userStore.isMobile ? 24 : 7">
                <el-form-item label="归属公司" prop="companyType">
                  <el-select @change="setCompanyTypeName" v-model="form.companyType" placeholder="请选择归属公司"
                    style="width: 100%">
                    <el-option v-for="dict in company_type" :key="dict.value" :label="dict.label"
                      :value="dict.value"></el-option>
                  </el-select>
                </el-form-item>
              </el-col>

              <el-col :span="userStore.isMobile ? 24 : 7">
                <el-form-item label="客户名称" prop="customerName">
                  <el-input v-model="form.customerName" placeholder="请输入客户名称" style="width: 100%" />
                </el-form-item>
              </el-col>

            </el-row>

            <el-row :gutter="userStore.isMobile ? 10 : 21">
              <el-col :span="userStore.isMobile ? 24 : 7">
                <el-form-item label="客户地址" prop="customerAddress">
                  <el-input v-model="form.customerAddress" placeholder="请输入客户地址" style="width: 100%" />
                </el-form-item>
              </el-col>
              <el-col :span="userStore.isMobile ? 24 : 7">
                <el-form-item label="项目配合单位" prop="projectUnit">
                  <el-input v-model="form.projectUnit" placeholder="请输入项目配合单位" style="width: 100%" />
                </el-form-item>
              </el-col>
            </el-row>

            <el-form-item label="备注" prop="remark">
              <el-input v-model="form.remark" type="textarea" :rows="3" placeholder="请输入备注" style="width: 100%" />
            </el-form-item>


            <el-divider style="font-size: 16px; font-weight: bold;">参与人员信息</el-divider>

            <div v-if="form.saleCom == '1'" style="display: flex; align-items: center;">
              <el-button type="primary" style="margin-bottom: 0px;" plain :icon="Plus"
                @click="addPerson('add')">添加参与人员</el-button>
              <el-alert style="margin-bottom: 20px;margin-left: 20px; max-width: 600px" title="提示:必须添加销售负责人"
                type="success" />
            </div>


            <el-table v-loading="loading" :data="personList" border style="width: 100%"
              @selection-change="handleSelectionChange">
              <el-table-column label="参与人" align="center" width="200" prop="participanName" />
              <el-table-column label="岗位" align="center" prop="postName" />
              <el-table-column label="开始日期" align="center" width="120" prop="startDate" />
              <el-table-column label="结束日期" align="center" prop="endDate" />
              <el-table-column label="备注" align="center" width="120" prop="remark" />
              <el-table-column label="操作人" align="center" prop="operator" />
              <el-table-column label="操作时间" align="center" prop="startDate" width="180">
                <template #default="scope">
                  <span>{{ parseTime(scope.row.createTime, "{y}-{m}-{d} {h}:{i}:{s}") }}</span>
                </template>
              </el-table-column>
              <el-table-column v-if="form.saleCom == '1'" label="操作" fixed="right"
                :width="userStore.isMobile ? 100 : 220" align="center" class-name="small-padding fixed-width">
                <template #default="scope">
                  <el-button link type="primary" :icon="userStore.isMobile ? '' : 'Edit'"
                    @click="handleUpdateParticipan(scope.row, scope.$index, 'edit')">修改</el-button>
                  <el-button link type="primary" :icon="userStore.isMobile ? '' : 'Delete'"
                    @click="handleDeleteParticipan(scope.row, scope.$index, 'delete')">删除</el-button>
                </template>
              </el-table-column>
            </el-table>


            <el-divider style="font-size: 16px; font-weight: bold;">附件信息</el-divider>
            <div
              v-if="form.saleCom == '1' && form.projectNo != undefined && form.projectNo != '' && form.projectNo != null"
              style="display: flex; align-items: center;">
              <el-button type="primary" plain :icon="Plus" @click="addFiles()"
                style="margin-bottom: 10px;">添加附件信息</el-button>
              <el-alert style="margin-bottom: 30px;margin-left: 20px; max-width: 600px"
                title="提示:必须上传:1.正式清单 2.验收单(货物签收单)" type="success" />
            </div>
            <el-table v-loading="loading" :data="attachmentList" border @selection-change="handleSelectionChange">
              <el-table-column label="附件类别" align="center" prop="attachmentType">
                <template #default="scope">
                  <dict-tag :options="file_type" :value="scope.row.attachmentType" />
                </template>
              </el-table-column>
              <el-table-column label="附件标题" align="center" prop="attachmentTitle" />
              <el-table-column label="附件名称" align="center" show-overflow-tooltip width="200" prop="fileName">
                <template #default="scope">
                  <el-link type="primary" @click="downloadFile(scope.row)">{{ scope.row.fileName }}</el-link>
                </template>
              </el-table-column>
              <el-table-column label="操作人" align="center" prop="operator" />
              <el-table-column label="操作时间" align="center" prop="startDate" width="180">
                <template #default="scope">
                  <span>{{ parseTime(scope.row.createTime, "{y}-{m}-{d} {h}:{i}:{s}") }}</span>
                </template>
              </el-table-column>
              <el-table-column v-if="form.saleCom == '1'" label="操作" align="center" fixed="right"
                :width="userStore.isMobile ? 120 : 220" class-name="small-padding fixed-width">
                <template #default="scope">
                  <el-button link type="primary" :icon="userStore.isMobile ? '' : 'Edit'"
                    @click="handleUpdateFile(scope.row)">修改</el-button>
                  <el-button link type="primary" :icon="userStore.isMobile ? '' : 'Delete'"
                    @click="handleDeleteFile(scope.row)">删除</el-button>
                </template>
              </el-table-column>
            </el-table>

          </el-form>
        </el-tab-pane>
        <el-tab-pane label="正式清单" name="second">
          <mainList v-if="activeName == 'second'" :datas="form"></mainList>
        </el-tab-pane>
        <el-tab-pane label="管家婆出库单" name="third">
          <saleList v-if="activeName == 'third'" :datas="form"></saleList>
        </el-tab-pane>
        <el-tab-pane label="费用汇总" name="four">
          <feeList v-if="activeName == 'four'" :datas="form"></feeList>
        </el-tab-pane>
        <el-tab-pane label="清单对比" name="five">
          <compareMainAndSale v-if="activeName == 'five'" :datas="form"></compareMainAndSale>
        </el-tab-pane>
        <el-tab-pane label="配套施工清单" name="six">
          <matching v-if="activeName == 'six'" :datas="form"></matching>
        </el-tab-pane>

        <el-tab-pane label="绩效预分配" v-if="isSaleManage" name="seven">
          <allocation v-if="activeName == 'seven'" ref="allocationRef"></allocation>
        </el-tab-pane>

        <el-tab-pane label="项目核算" name="eight">
          <accountingCom :projectNo="projectNo" v-if="activeName == 'eight'"> </accountingCom>
        </el-tab-pane>


        <el-tab-pane label="项目质保" name="nine">
          <warrantyInfo :projectNo="projectNo" v-if="activeName == 'nine'"> </warrantyInfo>
        </el-tab-pane>


      </el-tabs>
      <template #footer>
        <div class="dialog-footer">
          <el-button type="primary" @click="submitForm(1)"
            v-if="activeName == 'first' && form.saleCom == '1'">保存</el-button>

          <el-popconfirm v-if="activeName == 'nine' && form.saleCom == '1'" confirm-button-text="确认"
            cancel-button-text="取消" title="确认提交归档?" @confirm=projectComplete>
            <template #reference>
              <el-button type="primary">项目归档</el-button>
            </template>
          </el-popconfirm>

          <el-popconfirm v-if="activeName == 'nine' && form.saleCom == '2'" confirm-button-text="确认"
            cancel-button-text="取消" title="确认回退?" @confirm=projectBack>
            <template #reference>
              <el-button type="primary">项目回退</el-button>
            </template>
          </el-popconfirm>

          <el-button type="primary" v-if="form.saleCom == '1' && allTabs.indexOf(activeName) > 0"
            @click="prevStep()">上一步</el-button>
          <el-button type="primary" v-if="form.saleCom == '1' && allTabs.indexOf(activeName) < allTabs.length - 1"
            @click="nextStep">下一步</el-button>
          <el-button @click="cancel">关 闭</el-button>

        </div>
      </template>
    </el-dialog>

    <!-- 添加或修改项目参加人员子对话框 -->
    <el-dialog :title="title" v-model="openOper" :width="userStore.isMobile ? '95%' : '800px'" append-to-body>
      <el-form ref="participanRef" :model="personForm" size="large" :rules="personRules" label-width="120px">
        <!-- <el-form-item label="关联的阶段id" prop="phaseId">
          <el-input v-model="personForm.phaseId" placeholder="请输入关联的阶段id" />
        </el-form-item> -->
        <el-form-item label="参与人" prop="participantId">
          <el-select @change="setPersonName" filterable v-model="personForm.participantId" placeholder="请选择参与人"
            clearable style="width: 200px;">
            <el-option v-for="dict in userList" clearable :key="dict.userId" :label="dict.nickName"
              :value="dict.userId"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="参与人岗位" prop="postId">
          <el-select @change="setPostName" filterable v-model="personForm.postId" placeholder="请选择岗位" clearable
            style="width: 200px;">
            <el-option v-for="dict in posts" clearable :key="dict.postId" :label="dict.postName"
              :value="dict.postId"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="开始日期" prop="startDate">
          <el-date-picker clearable v-model="personForm.startDate" type="date" value-format="YYYY-MM-DD"
            placeholder="请选择开始日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="结束日期" prop="endDate">
          <el-date-picker clearable v-model="personForm.endDate" type="date" value-format="YYYY-MM-DD"
            placeholder="请选择结束日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="备注" prop="remark">
          <el-input v-model="personForm.remark" type="textarea" placeholder="请输入内容" />
        </el-form-item>
      </el-form>
      <template #footer>
        <div class="dialog-footer">
          <el-button type="primary" @click="submitPersonForm">确 定</el-button>
          <el-button @click="cancelPerson">取 消</el-button>
        </div>
      </template>
    </el-dialog>

    <!-- 添加或修改附件对话框 -->
    <el-dialog title="附件信息" v-model="openFile" :width="userStore.isMobile ? '95%' : '800px'" append-to-body>
      <el-form ref="attachmentRef" :model="fileForm" size="large" :rules="fileRules" label-width="100px">
        <el-form-item label="附件类别" prop="attachmentType">
          <el-select @change="setUploadType" v-model="fileForm.attachmentType" placeholder="请选择附件类别">
            <el-option v-for="dict in file_type" :key="dict.value" :label="dict.label" :value="dict.value"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="附件标题" prop="attachmentTitle">
          <el-input v-model="fileForm.attachmentTitle" placeholder="请输入附件标题" />
        </el-form-item>
        <el-form-item label="备注" prop="remark">
          <el-input v-model="fileForm.remark" type="textarea" placeholder="请输入内容" />
        </el-form-item>
        <el-form-item label="上传附件" prop="filePath">
          <file-upload :limit="1" :fileType="fileAccept" v-model="fileForm.filePath" />
        </el-form-item>

        <!-- <el-button @click="importTemplate">下载模板</el-button> -->
        <template v-if="fileForm.attachmentType == 5 || fileForm.attachmentType == 22"><el-tag type="primary"
            style="margin-left: 10px;">提示：多次导入正式清单或结算清单会以最后一份为准</el-tag></template>
        <!-- <template v-if="fileForm.attachmentType == 5"><el-icon><WarningFilled/></el-icon><el-tag type="success">正式清单F列数量为必填</el-tag></template> -->
      </el-form>
      <template #footer>
        <div class="dialog-footer">
          <el-button type="primary" @click="submitFileForm">确 定</el-button>
          <el-button @click="cancelFile">取 消</el-button>
        </div>
      </template>
    </el-dialog>
  </div>
</template>

<script setup name="Project">
import {
  listProjectSalePage,
  saleDetails, listWarranty,
  delProject,
  addSaleProject,
  updateSaleProject,
  syncData, getPermission,
  getPermissionSaleAndManage,
  getCompanyList,
  getAmountInfo, addWarranty,
  listCompany, checkSale,
  listParticipan, getParticipan, delParticipan, addParticipan, updateParticipan, getStatus,
  saveUserTableConfig, getUserTableConfig, getAllSaleRole, getAllSaleRoleXs
} from "@/api/project/project";
import {
  Plus
} from '@element-plus/icons-vue'
import { getInfo } from "@/api/login";
import { listAllUser, getUser } from "@/api/system/user";
import { useRouter } from 'vue-router';
import { listAttachment, getAttachment, delAttachment, addAttachment, updateAttachment, rollBackPhase } from "@/api/project/project";
import { getAuditPermission } from "@/api/project/allocation";
import { getCheck, checkCosting, getNextPermission, listDictionary, getDictionary, delDictionary, addDictionary, updateDictionary, listAllDictionary } from "@/api/project/dictionary";
import { listFee, delFee, addFee, updateFee, totalFee } from "@/api/project/fee";

const router = useRouter();

const saleRoleList = ref([])

getAllSaleRoleXs(null).then((response) => {
  saleRoleList.value = response.data
});

const saleCom = ref('0')

const haveNext = ref(false)
const { proxy } = getCurrentInstance();
const { project_type } = proxy.useDict("project_type");
const { company_type } = proxy.useDict("company_type");
const attachmentList = ref([]);
const posts = ref([])
const userList = ref([])
const projectList = ref([]);
const personList = ref([]);
const companyList = ref([]);
const open = ref(false);
const isView = ref(false);
const openView = ref(false);
const openOper = ref(false);
const openPhase = ref(false);
const loading = ref(true);
const showSearch = ref(true);
const ids = ref([]);
const single = ref(true);
const multiple = ref(true);
const total = ref(0);
const title = ref("");
const daterangeAcceptTime = ref([]);
const projectNo = ref(null)
const phasetList = ref([]);
const formDisabled = ref(true);
const currentIndex = ref(0)
const currentType = ref('')
const status = ref("1")
const currenrPhaseId = ref()
const loadingQuery = ref(false)
let currentPhase = reactive({
  phaseCode: '',
});
const { file_type } = proxy.useDict('file_type');

import { ref } from "vue";
import { updatePhase, addPhase, listAccounting } from "../../../api/project/project";

import { ElLoading } from 'element-plus'


const getCurrentStep = () => {
  if (activeName.value != 'nine') {
    return true
  } else {
    return false
  }
}




const nextStep = async () => {
  const currentIndex = visibleTabs.value.indexOf(activeName.value)
  if (currentIndex < visibleTabs.value.length - 1) {
    const nextTab = visibleTabs.value[currentIndex + 1]
    // const allowed = await canSwitchTo(nextTab)
    // if (allowed) {
    activeName.value = nextTab
    // }
    // 如果不允许，activeName 不变，UI 保持原样
  }
}

const prevStep = () => {
  const currentIndex = visibleTabs.value.indexOf(activeName.value)
  if (currentIndex > 0) {
    // 上一步通常不需要校验（或按需加）
    activeName.value = visibleTabs.value[currentIndex - 1]
  }
}



const allTabs = [
  'first',
  'second',
  'third',
  'four',
  'five',
  'six',
  'seven',   // ← 这个有条件
  'eight',
  'nine'
]

const visibleTabs = computed(() => {
  return allTabs.filter(tabName => {
    // 只有 'seven' 需要权限控制，其他都显示
    if (tabName === 'seven') {
      return isSaleManage.value
    }
    return true
  })
})


const data = reactive({
  warrantyForm: {},
  currentProject: {},
  form: {
    createUserName: null,
    createUserId: null,
    createDeptName: null,
    createDept: null,
    saleCom: '1'
  },
  fileForm: {
    phaseId: 99//

  },
  currentConfig: {//当前环节关联的配置表

  },
  personForm: {
    phaseId: 99//
  },
  queryParams: {
    pageNum: 1,
    pageSize: 10,
    projectName: null,
    projectType: null,
    projectUnit: null,
    customerName: null,
    housekeeperName: null,
  },
  rules: {
    projectName: [{ required: true, message: "项目名称不能为空", trigger: "blur" }],
    contractAmount: [{ required: true, message: "合同金额不能为空", trigger: "blur" }],
    settlementAmount: [{ required: true, message: "结算金额不能为空", trigger: "blur" }],
    housekeeperProject: [{ required: true, message: "管家婆项目不能为空", trigger: "blur" }],
    companyType: [{ required: true, message: "归属公司不能为空", trigger: "blur" }],
    projectType: [{ required: true, message: "项目类型不能为空", trigger: "blur" }],

  },
  personRules: {
    postId: [{ required: true, message: "岗位不能为空", trigger: "blur" }],
    participantId: [{ required: true, message: "参与人不能为空", trigger: "blur" }],
  },


  fileRules: {
    attachmentType: [{ required: true, message: "请选择附件类型", trigger: "blur" }],
    filePath: [{ required: true, message: "请上传附件", trigger: "blur" }],
  },

  amountInfo: {
    should: null,
    actual: null,
    remaining: null,
    gjpShould: null,
    same: null
  },

});






//添加参与人员
function addPerson(type) {
  currentType.value = type
  //重置表单
  resetPer()
  // personList.value = []
  if (currentConfig.value != null) {
    openOper.value = true
    title.value = "添加参与人员信息";
  } else {//请求失败 提示
    proxy.$modal.msgError("接口请求失败");
    return
  }

}

const openFile = ref(false)

//添加附件信息
function addFiles() {
  //重置表单
  resetFile()
  openFile.value = true
}

// 表单重置
function resetFile() {
  fileForm.value = {
    phaseId: 99
  };
  proxy.resetForm("attachmentRef");

}

// 获取文件名称
function getFileName(name) {
  if (name) {
    // 如果是url那么取最后的名字 如果不是直接返回
    if (name.lastIndexOf("/") > -1) {
      return name.slice(name.lastIndexOf("/") + 1);
    } else {
      return name;
    }
  }
}


/** 修改按钮操作 */
function handleUpdateFile(row) {
  resetFile();
  const _attachmentId = row.attachmentId || ids.value
  getAttachment(_attachmentId).then(response => {
    fileForm.value = response.data;
    openFile.value = true;
  });
}


function submitFileForm() {
  proxy.$refs["attachmentRef"].validate(valid => {
    if (valid) {

      // 定义 loading 实例变量
      let loadingInstance = null;
      if (fileForm.value.attachmentType == "5" || fileForm.value.attachmentType == "22") {
        //正数清单上传慢  加上loading
        loadingInstance = ElLoading.service({ fullscreen: true, text: '清单上传中...' });

      }


      fileForm.value.fileName = getFileName(fileForm.value.filePath)
      fileForm.value.projectNo = projectNo.value
      if (fileForm.value.attachmentId != null) {
        updateAttachment(fileForm.value).then(response => {
          proxy.$modal.msgSuccess("修改成功");
          if (loadingInstance) {
            loadingInstance.close();
          }
          openFile.value = false;
          getListParticipan(projectNo.value)
        }).finally(() => {
          loadingInstance.close();
        });
      } else {
        addAttachment(fileForm.value).then(response => {
          proxy.$modal.msgSuccess("新增成功");
          if (loadingInstance) {
            loadingInstance.close();
          }
          openFile.value = false;
          getListParticipan(projectNo.value)
        }).finally(() => {
          loadingInstance.close();
        });
      }
    }
  });
}


const { queryParams, form, rules, personForm, personRules, currentConfig, amountInfo, fileForm, warrantyForm } = toRefs(data);

const setHousekeeperName = (id) => {

  if (id == undefined) {
    form.value.housekeeperName = '';
    return
  }
  const filteredObjects = companyList.value.find((obj) => obj.id === id);
  form.value.housekeeperName = '';
  console.log("filteredObjects", filteredObjects);
  form.value.housekeeperName = filteredObjects?.companyName || '';
  console.log("setHousekeeperName", id, form.value.housekeeperName);
}


function selectCompany(query) {
  console.log("queryquery", query);
  loadingQuery.value = true
  let params = {
    companyName: query
  }
  listCompany(params).then((response) => {
    companyList.value = response.data
    loadingQuery.value = false
  });
}

function tets() {
  getUser().then(response => {
    posts.value = response.posts;
    console.log("岗位1111", response);
  });
  listAllUser().then(res => {
    console.log("userlist", res);
    userList.value = res
  });

}

const setProjectTypeName = (datas) => {
  //对应的名称
  const filteredObjects = project_type.value.filter((obj) => datas.includes(obj.value));
  form.value.projectTypeName = '';
  const labels = filteredObjects.map((obj) => obj.label);
  form.value.projectTypeName = labels.length > 1 ? labels.join(',') : labels[0] || '';

};


const setCompanyTypeName = (datas) => {
  //对应的名称
  const filteredObjects = company_type.value.filter((obj) => datas.includes(obj.value));
  form.value.companyName = '';
  const labels = filteredObjects.map((obj) => obj.label);
  form.value.companyName = labels.length > 1 ? labels.join(',') : labels[0] || '';

};



/** 查询绩效基本信息列表 */
function getList() {
  loading.value = true;
  queryParams.value.params = {};
  if (null != daterangeAcceptTime && "" != daterangeAcceptTime) {
    // queryParams.value.params["beginAcceptTime"] = daterangeAcceptTime.value[0];
    // queryParams.value.params["endAcceptTime"] = daterangeAcceptTime.value[1];
    queryParams.value.beginAcceptTime = daterangeAcceptTime.value[0];
    queryParams.value.endAcceptTime = daterangeAcceptTime.value[1];
  }

  getAllSaleRoleXs(null).then((response) => {
    saleRoleList.value = response.data
  });


  listProjectSalePage(queryParams.value).then((response) => {
    console.log("response", response);
    projectList.value = response.data.rows;
    total.value = response.data.total;
    loading.value = false;
    console.log('projectList', projectList);

  });


}

// 取消按钮
function cancel() {
  open.value = false;
  openView.value = false
  reset();
  getList()
}
// 取消按钮
function cancelPerson() {
  openOper.value = false;
  resetPer();
}


//获取用户详细信息
function getUserInfo() {
  getInfo()
    .then((res) => {
      const user = res.user;
      form.value.createUserName = user.nickName;
      form.value.createUserId = user.userId;
      form.value.createDeptName = user.dept.deptName
      form.value.createDept = user.deptId
      console.log("user", form);

    })
    .catch((error) => {
      console.log("error", error);
    });

}
// 表单重置
function reset() {
  form.value = {
    createUserName: null,
    createUserId: null,
    createDeptName: null,
    createDept: null,
    saleCom: '1'
  };
  proxy.resetForm("projectRef");
}

// 表单重置
function resetPer() {
  personForm.value = {
    phaseId: 99//
  };
  proxy.resetForm("participanRef");

}

/** 搜索按钮操作 */
function handleQuery() {
  queryParams.value.pageNum = 1;
  getList();
}


/** 同步数据 */
function handleSync() {
  syncData().then((response) => {
    proxy.$modal.msgSuccess("同步成功");
  });
}




/** 重置按钮操作 */
function resetQuery() {
  daterangeAcceptTime.value = [];
  proxy.resetForm("queryRef");
  queryParams.value.minProjectAmount = null
  queryParams.value.maxProjectAmount = null
  handleQuery();
}

// 多选框选中数据
function handleSelectionChange(selection) {
  ids.value = selection.map((item) => item.projectNo);
  single.value = selection.length != 1;
  multiple.value = !selection.length;
}

function setPostName(id) {
  // 筛选 posts.value 中符合条件的对象
  const filteredObjects = posts.value.filter((obj) => obj.postId === id);
  // 清空 projectTypeName 字段
  personForm.value.postName = '';
  console.log("postName", filteredObjects);
  personForm.value.postName = filteredObjects[0].postName
}

function setPersonName(id) {
  // 筛选 posts.value 中符合条件的对象
  const filteredObjects = userList.value.filter((obj) => obj.userId === id);
  // 清空 projectTypeName 字段
  personForm.value.participanName = '';
  console.log("filteredObjects[0]?.nickName", filteredObjects[0]?.nickName);

  personForm.value.participanName = filteredObjects[0]?.nickName

  console.log('6666666', personList);

}

/** 新增按钮操作 */
function handleAdd() {
  projectNo.value = null
  reset();
  activeName.value = 'first'
  personList.value = []
  attachmentList.value = []
  form.value.participanList = []
  open.value = true;
  title.value = "添加项目基本信息";
  form.value.startDate = getCurrentDateTime()
  form.value.approvalDate = getCurrentDate()
  form.value.createTime = getCurrentDateTime()
  getUserInfo()


  console.log("新增项目", form.value);



}

import amountView from "../amountView.vue";
const amountRef = ref()
const amountViewProjectNo = ref(0)
import projectView from "../projectView.vue";

const isSaleManage = ref(false)

/** 修改按钮操作 */
async function handleUpdate(row) {

  activeName.value = "first"
  projectNo.value = row.projectNo
  formDisabled.value = false

  const _projectNo = row.projectNo || ids.value;
  personForm.projectNo = row.projectNo
  await saleDetails(_projectNo).then((response) => {
    reset();
    form.value = response.data;
    if (form.value.housekeeperName) {
      selectCompany(form.value.housekeeperName)
    }
    open.value = true;
    title.value = "";
  });
  getListParticipan(row.projectNo)
}


async function getListParticipan(projectNo) {
  let params = {
    projectNo: projectNo
  }
  listParticipan(params).then((response) => {
    console.log("参与人员信息", response);
    personList.value = response.data
  });

  listAttachment(params).then((response) => {
    attachmentList.value = response.data;
    console.log("项目附件", attachmentList.value);

  });

  //控制显示隐藏绩效预分配 与普通项目一样 

  //检查是否有进入绩效预分配的权限  销售负责 项目经理
  let saleParams = {
    projectNo: projectNo,
    postIds: [5, 2]
  }
  const res = await getPermissionSaleAndManage(saleParams);

  isSaleManage.value = res.data


}


function handleUpdateParticipan(row, index, type) {
  currentType.value = type
  currentIndex.value = index
  //重置表单
  console.log("rowrow", row, index);
  resetPer()
  const _projectNo = row.projectNo || ids.value;
  personForm.projectNo = row.projectNo
  console.log("修改", row);
  if (row.projectNo) {

  }

  openOper.value = true
  personForm.value = row

}


function handleDeleteFile(row) {
  const _attachmentIds = row.attachmentId || ids.value;
  proxy.$modal.confirm('是否确认删除？').then(function () {
    return delAttachment(_attachmentIds);
  }).then(() => {
    getListParticipan(projectNo.value)
    proxy.$modal.msgSuccess("删除成功");
  }).catch(() => { });
}


function handleDeleteParticipan(row, index, type) {
  currentType.value = type
  console.log("indexindexindex", index);
  proxy.$modal
    .confirm('是否确认删除？')
    .then(async () => {
      if (row.id) {
        await delParticipan(row.id)
        getListParticipan(form.value.projectNo)
      }
      personList.value.splice(index, 1); // 删除指定索引的元素
    })
    .catch((error) => {
      // 捕获错误并提示用户
      console.error("删除操作失败", error);
    });
}

import allocation from "../allocation.vue";
import accountingCom from './accounting.vue'
import warrantyInfo from './warranty.vue'
import { listMatching, getMatchingTotal } from "@/api/project/matching";
const allocationRef = ref()
//验收环节预分配
import { getAllocationMoney } from "@/api/project/allocation";
import { reCreateWarranty } from "@/api/project/allocation";
import mainList from "../mainList.vue";
import saleList from "../saleList.vue";
import feeList from "../fee.vue"
import compareMainAndSale from "../compareMainAndSale.vue"
import { listCosting, getCosting, delCosting, addCosting, updateCosting } from "@/api/project/costing";

import matching from "./matching.vue"
const activeName = ref('first')
async function handleClick(item, event) {
  // activeName.value = item.paneName
}

// 🔒 切换锁：防止重复点击导致多次调用
const isSwitching = ref(false)


// el-tabs 的 before-leave 回调（newName, oldName）
async function beforeTabLeave(newTabName, oldTabName) {
  // 如果点击的是当前 tab，放行
  if (newTabName === oldTabName) return true
  if (activeName.value == 'first' && form.value.saleCom == '1') {
    await submitForm()
  }

  // 复用校验逻辑
  return await canSwitchTo(newTabName, oldTabName)
}

// 判断是否允许切换到 newTabName（不含 oldTabName，因为按钮导航不需要 oldTab）
async function canSwitchTo(newTabName, oldTabName) {
  // 如果是 first，直接放行（首页无需校验）
  if (newTabName === 'first') {
    return true
  }

  // 防重：如果正在切换中，拒绝
  if (isSwitching.value) {
    console.warn('切换正在进行中，忽略重复请求')
    return false
  }

  isSwitching.value = true

  try {
    // 1. 检查销售负责人
    const params = { projectNo: projectNo.value }
    const check = await checkSale(params)
    if (!check) {
      proxy.$modal.msgError("请完善项目基本信息,添加销售负责人!")
      activeName.value = oldTabName
      return false
    }

    // 2. 特殊 tab 的额外校验
    if (newTabName === 'eight') {
      console.log("aaaaaaa");
      //   核算权限
      const saleParams = { projectNo: projectNo.value, postIds: [5] }
      const res = await getPermission(saleParams)
      if (!res.data) {
        proxy.$modal.msgError("暂无权限进行核算!")
        activeName.value = oldTabName
        return false
      }

      // 绩效分配是否完成
      const allocationPar = { projectNo: projectNo.value }
      const response = await getAuditPermission(allocationPar)


      if (response.data?.flag === false) {
        proxy.$modal.msgError(response.data.msg)
        activeName.value = oldTabName
        return false
      }

    }

    if (newTabName === 'nine') {

      //校验核算信息

      const acc = await listAccounting(params);
      if (acc.data == null || acc.data.length == 0) {
        proxy.$modal.msgError("还未添加核算信息!")
        activeName.value = oldTabName
        return false
      }


      const allocationPar = { projectNo: projectNo.value }
      const response = await getAuditPermission(allocationPar)
      if (response.data?.flag === false) {
        proxy.$modal.msgError(response.data.msg)
        activeName.value = oldTabName
        return false
      }

      const params1 = { projectNo: projectNo.value, current: "1" }
      const moneyRes = await getAllocationMoney(params1)
      if (moneyRes.data.allCommission !== moneyRes.data.already) {
        proxy.$modal.msgError(
          `核算环节:项目提成有变化,已分配的项目提成为:${moneyRes.data.already},最新的项目提成为:${moneyRes.data.allCommission},请点击绩效分配按钮重新计算生成`
        )
        activeName.value = oldTabName
        return false
      }

      //质保金为0  自动归档

      if (acc.data[0]?.retentionMoney <= 1 && form.value.saleCom == '1') {
        console.log("acc.data[0]?.retentionMoney", acc.data[0]?.retentionMoney);
        await projectCompleteNew()


      }

    }

    return true // ✅ 允许切换
  } catch (error) {
    console.error('校验失败:', error)
    activeName.value = oldTabName
    return false
  } finally {
    isSwitching.value = false
  }
}


watch(
  () => activeName.value,
  async (newName) => {
    //绩效预分配
    if (newName === 'seven') {
      // 确保组件已渲染（虽然 v-if 已满足，但可能需要 nextTick）
      await nextTick();

      // 获取数据
      const response = await saleDetails(projectNo.value);
      form.value = response.data;

      // 初始化子组件
      if (allocationRef.value) {
        console.log("isSaleManage", isSaleManage.value);

        if (form.value.saleCom == '1') {
          allocationRef.value.initData(form.value, "1", 'accept');
        } else {
          allocationRef.value.initData(form.value, "2", 'accountingComplete');
        }


      } else {
        console.error("allocationRef is still not available!");
      }
    }


  }
);


/** 提交按钮 */
function submitForm(type) {
  console.log("参与人员", personList);


  form.value.participanList = personList.value;
  proxy.$refs["projectRef"].validate(async (valid) => {

    if (valid) {
      if (form.value.projectNo != null) {
        updateSaleProject(form.value).then((response) => {
          proxy.$modal.msgSuccess("提交成功");
          // open.value = false;
          getList();
          getListParticipan(form.value.projectNo)
        });
      } else {
        await addSaleProject(form.value).then(async (response) => {
          proxy.$modal.msgSuccess("新增成功");
          console.log("新增", response.data.projectNo);

          await saleDetails(response.data.projectNo).then((response) => {
            form.value = response.data;
            projectNo.value = response.data.projectNo
            console.log("status.value", status.value, projectNo.value);
          });

          getListParticipan(response.data.projectNo)
          // open.value = false;

          // getList();
        });
      }
    }
  });
}

const warrantyList = ref([])


async function projectBack() {
  await saleDetails(projectNo.value).then((response) => {
    form.value = response.data;
    projectNo.value = response.data.projectNo
    console.log("status.value", status.value, projectNo.value);
  });

  form.value.saleCom = '1'
  updateSaleProject(form.value).then((response) => {
    proxy.$modal.msgSuccess("提交成功");
    open.value = false;
    getList();
  });
}



async function projectCompleteNew() {
  warrantyForm.value = {
  };
  warrantyForm.value.projectNo = form.value.projectNo
  warrantyForm.value.company = form.value.company
  warrantyForm.value.receivedAmount = 0
  warrantyForm.value.settlementAmount = form.value.settlementAmount
  warrantyForm.value.cycle = 0



  await addWarranty(warrantyForm.value)
  let params = {
    projectNo: projectNo.value
  }

  //质保信息
  const wadata = await listWarranty(params);
  warrantyList.value = wadata.data;


  //如果有质保金  去做质保金部分的绩效分配
  let paramsWa = {
    projectNo: projectNo.value,
    current: 2
  }
  reCreateWarranty(paramsWa).then((response) => {
    console.log("质保金部分", response);
  });


  await saleDetails(projectNo.value).then((response) => {
    form.value = response.data;
    projectNo.value = response.data.projectNo
    console.log("status.value", status.value, projectNo.value);
  });

  form.value.saleCom = '2'
  updateSaleProject(form.value).then((response) => {
    proxy.$modal.msgSuccess("提交成功");
    open.value = false;
    getList();
  });
}



async function projectComplete() {

  //质保信息
  await listWarranty(params).then((response) => {
    warrantyList.value = response.data;
  });


  if (warrantyList.value?.length > 0) {

    if (warrantyList.value[0].receivedAmount === undefined || warrantyList.value[0].receivedAmount === null) {
      proxy.$modal.msgError("请先添加质保实收金额");
      return
    }
    if (warrantyList.value[0].warranty != warrantyList.value[0].receivedAmount) {
      await proxy.$modal.confirm('质保金为' + warrantyList.value[0].warranty + ',质保实收金额为:' + warrantyList.value[0].receivedAmount + '，确认提交至归档环节?')
        .then(() => {
          // 用户点击了确定，继续执行后续操作
          console.log("用户确认提交");
          // 这里可以放你要执行的代码
        })
        .catch(() => {
          // 用户点击了取消，直接返回
          console.log("用户取消提交");
          return;
        });
    }

  }

  //如果有质保金  去做质保金部分的绩效分配
  let paramsWa = {
    projectNo: projectNo.value,
    current: 2
  }
  reCreateWarranty(paramsWa).then((response) => {
    console.log("质保金部分", response);
  });


  await saleDetails(projectNo.value).then((response) => {
    form.value = response.data;
    projectNo.value = response.data.projectNo
    console.log("status.value", status.value, projectNo.value);
  });

  form.value.saleCom = '2'
  updateSaleProject(form.value).then((response) => {
    proxy.$modal.msgSuccess("提交成功");
    open.value = false;
    getList();
  });



}



// 取消按钮
function cancelFile() {
  openFile.value = false;
  resetFile();
}




/** 提交按钮 */
function submitPersonForm() {

  if (projectNo.value) {
    proxy.$refs["participanRef"].validate(valid => {
      if (valid) {
        personForm.value.projectNo = projectNo.value
        if (personForm.value.id != null) {
          updateParticipan(personForm.value).then(response => {
            proxy.$modal.msgSuccess("提交成功");
            openOper.value = false;
            getListParticipan(projectNo.value)
          });
        } else {
          addParticipan(personForm.value).then(response => {
            proxy.$modal.msgSuccess("提交成功");
            openOper.value = false;
            getListParticipan(projectNo.value)
          });
        }
      }
    });

  } else {
    proxy.$refs["participanRef"].validate((valid, errors) => {
      // 验证通过，处理数据
      try {

        if (personForm.value.id != null && personForm.value.id != undefined) {
          // 查找是否有匹配的 id
          const index = personList.value.findIndex(item => item.id === personForm.value.id);
          if (index !== -1) {
            // 如果找到匹配的 id，替换对应下标的数据
            personList.value[index] = { ...personForm.value }; // 使用扩展运算符创建新对象以避免引用问题
          } else {
            // 如果没有找到匹配的 id，直接添加到列表中
            personList.value.push({ ...personForm.value });
          }
        } else {
          // 如果 id 不存在，直接添加到列表中
          if (currentType.value == 'add') {
            console.log('新增add',);
            personList.value.push({ ...personForm.value });
          }
          if (currentType.value == 'edit') {
            console.log('编辑edit',);
            personList.value[currentIndex.value] = { ...personForm.value }
          }

        }
        // getListParticipan(projectNo.value)
        // 关闭操作窗口
        openOper.value = false;

        // 提示成功
        // proxy.$modal.msgSuccess("操作成功");
      } catch (error) {
        // 捕获错误并提示用户
        console.error("操作失败", error);
        proxy.$modal.msgError("操作失败，请稍后再试");
      }
    });
  }
}



/** 删除按钮操作 */
function handleDelete(row) {
  const _projectNos = row.projectNo || ids.value;
  proxy.$modal
    .confirm('是否确认删除绩效基本信息编号为"' + _projectNos + '"的数据项？')
    .then(function () {
      return delProject(_projectNos);
    })
    .then(() => {
      getList();
      proxy.$modal.msgSuccess("删除成功");
    })
    .catch(() => { });
}


async function downloadFile(row) {
  //只有项目经理 销售负责人 吴总 能够下载正式清单 竣工结算清单 正式合同
  if (row.attachmentType == '4' || row.attachmentType == '5' || row.attachmentType == '22') {
    let params = {
      projectNo: row.projectNo,
      postIds: [2, 5, 6, 7]//传入岗位id  项目经理id 2  销售负责人 5  销售 9 商务 7 财务 6
    }
    const res = await getPermission(params).then((response) => {
      console.log("下载附件", response.data);
      return response.data
    });
    if (!res) {
      proxy.$modal.msgError("暂无权限下载此附件");
      return
    }
  }

  var name = row.fileName;
  var url = row.filePath || row.files;
  // var suffix = url.substring(url.lastIndexOf("."), url.length);
  const a = document.createElement('a')
  a.setAttribute('download', name)
  a.setAttribute('target', '_blank')
  a.setAttribute('href', import.meta.env.VITE_APP_BASE_API + url)
  a.click()
}


/** 导出按钮操作 */
function handleExport() {
  proxy.download(
    "system/project/export",
    {
      ...queryParams.value,
    },
    `project_${new Date().getTime()}.xlsx`
  );
}

function getCompanys() {
  // getCompanyList(queryParams.value).then((response) => {
  //   companyList.value = response.data.map(item => ({
  //     ...item, // 保留原始属性
  //     value: item.id, // 添加 value 字段
  //     label: item.companyName, // 添加 label 字段
  //   }));

  // });
}

function getCurrentDateTime() {
  const now = new Date();
  const year = now.getFullYear();
  const month = String(now.getMonth() + 1).padStart(2, '0');
  const day = String(now.getDate()).padStart(2, '0');
  const hours = String(now.getHours()).padStart(2, '0');
  const minutes = String(now.getMinutes()).padStart(2, '0');
  const seconds = String(now.getSeconds()).padStart(2, '0');
  console.log("ssssssssssssssssss");
  // form.startDate =  `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
  return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
};


function getCurrentDate() {
  const now = new Date();
  const year = now.getFullYear();
  const month = String(now.getMonth() + 1).padStart(2, '0');
  const day = String(now.getDate()).padStart(2, '0');
  console.log("ssssssssssssssssss");
  // form.startDate =  `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
  return `${year}-${month}-${day}`;
};


// 获取当前路由对象
const route = useRoute();

// 获取查询参数
const row = route.query.row;
console.log("路由。。。", row)
if (row) {
  // handleUpdate(row)
}


getList();
getCompanys();
tets()


onMounted(() => {
  loadUserColumnConfig()
});





// 所有可用列配置（可从接口获取）
const allColumns = [
  { label: "项目名称", prop: "projectName", visible: true },
  { label: "发起人", prop: "createUserName", visible: true },
  { label: "合同金额", prop: "contractAmount", visible: true },
  { label: "结算金额", prop: "settlementAmount", visible: true },
  { label: "客户名称", prop: "customerName", visible: true },
  { label: "管家婆项目", prop: "housekeeperName", visible: true },
  { label: "项目类型", prop: "projectTypeName", visible: true },
]

// 用户当前选择的列 props（由 el-checkbox-group 控制）
const selectedProps = ref([])

// 当前可见列列表（根据 selectedProps 排序后的结果）
const visibleColumns = computed(() => {
  return selectedProps.value
    .map(prop => allColumns.find(col => col.prop === prop))
    .filter(Boolean)
})



const getWidth = (prop) => {
  switch (prop) {
    case 'projectName':
    case 'approvalDate':
    case 'updateTime':
    case 'acceptTime':
      return 200;
    case 'housekeeperName':
      return 300;
    default:
      return undefined;
  }
}

async function loadUserColumnConfig() {
  const res = await getUserTableConfig({ type: "projectInfo" })

  let defaultOrder = allColumns
    .filter(col => col.visible !== false) // 可以根据 visible 控制是否默认显示
    .map(col => col.prop)

  if (res.data && Array.isArray(res.data)) {
    // 使用用户保存的顺序（只保留合法的 prop）
    selectedProps.value = res.data.filter(prop =>
      allColumns.some(col => col.prop === prop)
    )
  } else {
    // 否则使用默认顺序
    selectedProps.value = defaultOrder
  }
}


import useUserStore from '@/store/modules/user'

const userStore = useUserStore()



</script>


<style scoped>
.el-alert {
  margin: 20px 0 0;
}

.el-alert:first-child {
  margin: 0;
}
</style>